package Test;

import javax.swing.*;
import java.awt.*;

public class ImgTest {
    private static void ImgTest(){

        JFrame frame = new JFrame("图片");
        frame.setSize(400,500);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocation(300,200);
        frame.setVisible(true);

        JLabel label1 = new JLabel();
        ImageIcon icon = new ImageIcon("捕获3.png");
        Image image =icon.getImage();
        icon.setImage(image);
        label1.setIcon(icon);

        frame.add(label1);
    }

    public static void main(String[] args) {
SwingUtilities.invokeLater(ImgTest::ImgTest);
    }
}
